/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.site.user.pojo;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author zhanjun
 */
@Entity
@Table(name = "tb_user")
@NamedQueries({
    @NamedQuery(name = "TbUser.findAll", query = "SELECT t FROM TbUser t"),
    @NamedQuery(name = "TbUser.findByIdUser", query = "SELECT t FROM TbUser t WHERE t.idUser = :idUser"),
    @NamedQuery(name = "TbUser.findByUserName", query = "SELECT t FROM TbUser t WHERE t.userName = :userName"),
    @NamedQuery(name = "TbUser.findByUserPwd", query = "SELECT t FROM TbUser t WHERE t.userPwd = :userPwd"),
    @NamedQuery(name = "TbUser.findByNickName", query = "SELECT t FROM TbUser t WHERE t.nickName = :nickName"),
    @NamedQuery(name = "TbUser.findByPhone", query = "SELECT t FROM TbUser t WHERE t.phone = :phone"),
    @NamedQuery(name = "TbUser.findByEmail", query = "SELECT t FROM TbUser t WHERE t.email = :email"),
    @NamedQuery(name = "TbUser.findByCitycode", query = "SELECT t FROM TbUser t WHERE t.citycode = :citycode"),
    @NamedQuery(name = "TbUser.findByCity", query = "SELECT t FROM TbUser t WHERE t.city = :city"),
    @NamedQuery(name = "TbUser.findByIcq", query = "SELECT t FROM TbUser t WHERE t.icq = :icq"),
    @NamedQuery(name = "TbUser.findBySex", query = "SELECT t FROM TbUser t WHERE t.sex = :sex"),
    @NamedQuery(name = "TbUser.findByComment", query = "SELECT t FROM TbUser t WHERE t.comment = :comment"),
    @NamedQuery(name = "TbUser.findBySign", query = "SELECT t FROM TbUser t WHERE t.sign = :sign")})
public class TbUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_USER")
    private String idUser;
    @Column(name = "USER_NAME")
    private String userName;
    @Column(name = "USER_PWD")
    private String userPwd;
    @Column(name = "NICK_NAME")
    private String nickName;
    @Column(name = "PHONE")
    private String phone;
    @Column(name = "EMAIL")
    private String email;
    @Column(name = "CITYCODE")
    private String citycode;
    @Column(name = "CITY")
    private String city;
    @Column(name = "ICQ")
    private String icq;
    @Column(name = "SEX")
    private String sex;
    @Column(name = "COMMENT")
    private String comment;
    @Column(name = "SIGN")
    private String sign;
    @JoinTable(name = "tb_user_group", joinColumns = {
        @JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")}, inverseJoinColumns = {
        @JoinColumn(name = "ID_GROUP", referencedColumnName = "ID_GROUP")})
    @ManyToMany(fetch=FetchType.EAGER)
    private Set<TbGroup> tbGroupSet;
    @JoinTable(name = "tb_user_role", joinColumns = {
        @JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")}, inverseJoinColumns = {
        @JoinColumn(name = "ID_ROLE", referencedColumnName = "ID_ROLE")})
    @ManyToMany(fetch=FetchType.EAGER)
    private Set<TbRole> tbRoleSet;

    public TbUser() {
    }

    public TbUser(String idUser) {
        this.idUser = idUser;
    }

    public String getIdUser() {
        return idUser;
    }

    public void setIdUser(String idUser) {
        this.idUser = idUser;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPwd() {
        return userPwd;
    }

    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCitycode() {
        return citycode;
    }

    public void setCitycode(String citycode) {
        this.citycode = citycode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getIcq() {
        return icq;
    }

    public void setIcq(String icq) {
        this.icq = icq;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public Set<TbGroup> getTbGroupSet() {
        return tbGroupSet;
    }

    public void setTbGroupSet(Set<TbGroup> tbGroupSet) {
        this.tbGroupSet = tbGroupSet;
    }

    public Set<TbRole> getTbRoleSet() {
        return tbRoleSet;
    }

    public void setTbRoleSet(Set<TbRole> tbRoleSet) {
        this.tbRoleSet = tbRoleSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUser != null ? idUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbUser)) {
            return false;
        }
        TbUser other = (TbUser) object;
        if ((this.idUser == null && other.idUser != null) || (this.idUser != null && !this.idUser.equals(other.idUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.site.user.pojo.TbUser[idUser=" + idUser + "]";
    }

}
